package mashuaiproject.mashuaiproject.dto;

import lombok.Data;
import mashuaiproject.mashuaiproject.exption.CustomizeCode;
import mashuaiproject.mashuaiproject.exption.CustomizeException;

@Data
public class ResultDto {
    private  Integer code;//错误码数
    private  String  message;//提示

    public static  ResultDto erroOf(Integer code,String message){

        ResultDto resultDto=new ResultDto();
        resultDto.setCode(code);
        resultDto.setMessage(message);
        return resultDto;
    }

    public static ResultDto erroOf(CustomizeCode noLogin) {
        return  erroOf(noLogin.getCode(),noLogin.getMessage());
    }

    public static ResultDto okOf(){
        ResultDto resultDto=new ResultDto();
        resultDto.setCode(200);
        resultDto.setMessage("请求成功");
        return resultDto;
    }

    public static Object erroOf(CustomizeException ex) {
        return erroOf(ex.getCode(),ex.getMessage());
    }
}
